package com.classic.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.classic.base.UBaseApplication;



/**
 * 广告开关工具类
 */
public class ADUtils {
    private static final String DEFAULT_NAME = "AD_switch";
    private static ADUtils sInstance = null;
    private SharedPreferences spf = null;

    private String mSwitch = "switch";//广告开关

    private ADUtils() {
        spf = UBaseApplication.getInstance().getSharedPreferences(DEFAULT_NAME, Context.MODE_PRIVATE);
    }

    public synchronized static ADUtils getInstance() {
        if (sInstance == null) {
            sInstance = new ADUtils();
        }
        return sInstance;
    }

    /**
     * @param isShow 是否默认
     */
    public void setSwitch(boolean isShow) {
        spf.edit().putBoolean(mSwitch, isShow).apply();
    }

    /**
     * @return true 广告开启 false 广告关闭
     */
    public boolean getSwitch() {
        return spf.getBoolean(mSwitch, false);
    }



}